from PIL import Image
import re

img = Image.new('RGBA', (1024, 512))
#img = Image.open('saved.bmp')
print(img.size)

file = open('painted.txt', 'r')

s = file.readline()

str = re.compile("(\d+)")

while s:
    s = file.readline()
    # print(s)
    Lst = re.findall(str, s)
    if len(Lst) == 0 :
        break
    #print(Lst[0], Lst[1], Lst[2], Lst[3], Lst[4])
    img.putpixel((int(Lst[0]), int(Lst[1])),
                 (int(Lst[2]), int(Lst[3]), int(Lst[4])))

img.save('saved.bmp')
img.close()
print("program already done")